from awvs.base import Base
import requests
from lib.cache import file_cache

DEFAULT_POLICY = {"checks": ["wvs/location/cors_origin_validation.js", "wvs/CSRF", "wvs/SlowHTTPDOS",
                             "wvs/Scripts/PerFile/Javascript_Libraries_Audit.script", "ovas/"], "custom": True, "name": "CustomScan"}

class ScanningProfile(Base):
    @file_cache()
    def custom_policy(self, policy=DEFAULT_POLICY):
        api = self.url + '/scanning_profiles'
        r = self.session.post(api, json=policy)
        print(r.content)
        if r.status_code == 201:
            policy_res = r.json()
            return policy_res['profile_id']
        else:
            print('Add custom policy failed')
            return ''
